package com.ld.security.server.user.modules.rec.conver;

import com.hankcs.hanlp.HanLP;
import com.ld.security.common.core.base.ESuperEntity;
import com.ld.security.common.core.base.column.ListJson;
import com.ld.security.common.core.util.GenericUtil;
import com.ld.security.server.user.modules.rec.entity.RecItemEntity;
import com.ld.security.server.user.modules.ups.constant.UpsKeywordConstant;

import java.util.List;

/**
 * 推荐转换器
 * @param <E>
 */
public interface RecItemConver<E extends ESuperEntity>  {

    RecItemEntity conver(E e);



    default boolean isConver(E e){
        return getEntityClass() == e.getClass();
    }
    /**
     * 得到关键字
     * @param content
     * @param number
     * @return
     */
    default ListJson getKeywordList(String content, int number){
        List<String> contentList = HanLP.extractKeyword(content, number);
        ListJson listJson = new ListJson();
        listJson.addAll(contentList);
        return listJson;
    }

    default Class<E> getEntityClass()
    {
        return (Class<E>) GenericUtil.getGeneric(this.getClass(), RecItemConver.class, 0);
    }
}
